package com.foo.web.controller.wechat;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.foo.common.annotation.Log;
import com.foo.common.enums.BusinessType;
import com.foo.wechat.domain.WxBanner;
import com.foo.wechat.service.IWxBannerService;
import com.foo.common.core.controller.BaseController;
import com.foo.common.core.domain.AjaxResult;
import com.foo.common.utils.poi.ExcelUtil;
import com.foo.common.core.page.TableDataInfo;

/**
 * 首页轮播Controller
 *
 * @author foo
 * @date 2025-11-13
 */
@Controller
@RequestMapping("/wechat/WxBanner")
public class WxBannerController extends BaseController
{
    private String prefix = "wechat/WxBanner";

    @Autowired
    private IWxBannerService wxBannerService;

    @RequiresPermissions("wechat:WxBanner:view")
    @GetMapping()
    public String WxBanner()
    {
        return prefix + "/WxBanner";
    }

    /**
     * 查询首页轮播列表
     */
    @RequiresPermissions("wechat:WxBanner:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WxBanner wxBanner)
    {
        startPage();
        List<WxBanner> list = wxBannerService.selectWxBannerList(wxBanner);
        return getDataTable(list);
    }


    /**
     * 新增首页轮播
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存首页轮播
     */
    @RequiresPermissions("wechat:WxBanner:add")
    @Log(title = "首页轮播", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WxBanner wxBanner)
    {
        return toAjax(wxBannerService.insertWxBanner(wxBanner));
    }


    /**
     * 删除首页轮播
     */
    @RequiresPermissions("wechat:WxBanner:remove")
    @Log(title = "首页轮播", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wxBannerService.deleteWxBannerByIds(ids));
    }
}
